package models.admin;

import models.BaseModel;
import models.admin.enums.AdminUserType;
import models.constants.AvailableStatus;

import javax.persistence.*;

/**
 * Created by liming on 16/7/4.
 */
@Entity
@Table(name = "admin_role")
public class AdminRole extends BaseModel{
    /**
     * 角色编号
     */
    @Column(name = "code")
    public String code;
    /**
     * 角色名称
     */
    @Column(name = "name")
    public String name;

    /**
     * 菜单ID
     */
    @Column(name = "menu_id")
    public Long menuId;

    /**
     * 当前状态  禁用\可用
     */
    @Column(name = "available_status")
    @Enumerated(EnumType.STRING)
    public AvailableStatus status;
    /**
     * 角色类型
     */
    @Column(name = "role_type")
    @Enumerated(EnumType.STRING)
    public AdminUserType roleType;
    /**
     * 备注
     */
    @Column(name = "remark")
    public String remark;

    /**
     *
     * @param roleType
     * @return
     */
    public static AdminRole getByRoleType (AdminUserType roleType){
        return AdminRole.find(" roleType = ? order by id" , roleType).first();
    }

}
